//
//  TheNewClueShowTableViewController.m
//  MagazineShangejie
//
//  Created by cnbizMedia on 15/9/24.
//  Copyright © 2015年 CnbizMedia. All rights reserved.
//

#import "TheNewClueShowTableViewController.h"
#import "Util.h"
#import "DiscoveryTableView.h"
#import "UMSocial.h"
@interface TheNewClueShowTableViewController (){
    NSMutableDictionary*dic_m;
    
    UIView*headerView;
    NSMutableArray*headerButtons;
    NSMutableArray*userData;
    
    
    IBOutlet UITableView *theTableView;
    __weak IBOutlet UITableView *questionTableView;
//    __weak IBOutlet UITableViewCell *higCell;
    
    NSDictionary *wordDic;
    NSArray *titleArray;
    NSMutableArray *wordArray;
    
    int cellHight;
    
    UITableViewCell *cell ;
    UITableViewCell *hightCell ;
    UITableViewCell *questionCell ;
    NSMutableArray  *questionDicArray;
    NSURL *shareURL;
    
    int number;
    
    NSMutableArray *cellheightArray;
}

@end

@implementation TheNewClueShowTableViewController


//这个新添加的clueShow相比之前的从新写了一个tableView，不同的界面用不同的cel的identifier
- (void)viewDidLoad {
    [super viewDidLoad];
    cellheightArray = [[NSMutableArray alloc] init ];
    [SVProgressHUD showWithStatus:@"数据加载中..." maskType:SVProgressHUDMaskTypeClear];
    
    NSLog(@"[_scrollAnchorView.frame.origin.y ]%@",self.navigationController ) ;
    
    
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
 
    
    //2. 取出数据
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    number = [userDefault integerForKey:@"buttonTagNumber"];
    
    switch (number) {
        case 0:
            self.title = @"论坛";
            titleArray = @[@"活动介绍"];
            
            NSLog(@"wordArray -- %@",wordArray);
            break;
            
        case 1:
            self.title = @"游学";
            titleArray = @[@"行程特色",@"行程安排"];//
            break;
            
        case 2:
            self.title = @"咨询";//这里分成了两个界面，一个是永道招商，一个是智放
            break;
            
        case 3:
            self.title = @"创投";
            titleArray = @[@"项目简介",@"核心优势",@"融资进度",@"目前规模",@"未来预期"];//   核心优势  融资进度  目前规模  未来预期
            
            break;
            
        case 4:
            self.title = @"咨询";//永道招商
            titleArray = @[@"项目概况",@"品牌述求",@"策略回顾",@"效果总结"];//
 
            break;
            
        case 5:
            self.title = @"咨询";//智放
            titleArray = @[@"项目概况",@"挑战来袭",@"突围之道",@"丰硕成果"];//
 
            break;
            
        default:
            break;
    }

    
    
   
    
    
    
    NSDictionary *lunTanDic = [userDefault objectForKey:@"lunTanDic"];
    
    NSString *idString = [lunTanDic objectForKey:@"id"];
    NSString *catid    = [lunTanDic objectForKey:@"catid"];
    
    NSDictionary *parameter=@{@"catid":catid,@"id":idString};
    
    [[AppAPIClient sharedClient] GET:@"Club/Show" parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"operation = =%@",operation);
        shareURL = operation.request.URL;
        NSLog(@"shareURL -- %@",shareURL);
        
        NSMutableDictionary *result = responseObject[@"data"];
        NSLog(@"luntan-data == %@",result);
        if([result isKindOfClass:[NSNull class]] || [result count] == 0){
            return;
        }
        if([result isKindOfClass:[NSNull class]] || [result count] == 0||[result[@"content"] count]==0){
            return;
        }
        
        wordDic = nil;
        
        wordDic = [[NSDictionary alloc] initWithDictionary:result[@"content"] copyItems:YES ];
        NSLog(@"wordDic -- %@",wordDic);
        
        
        /*
         "id": "1",
         "catid": "3671",
         "title": "俱乐部论坛测试数据一",
         "thumb": "http://www.kanshangjie.com/uploadfile/2015/0911/20150911054954864.jpg",
         "inputtime": "1441964932",
         "activitytime": "2015-09-11 17:48:00",
         "activitystatus": "2",
         "number": "10",
         "area": "陕西省汉中市南郑县",
         "content": "<p>这里是活动详情</p>\r\n<p>这里是换行内容</p>\r\n",
         "address": "郑家院子"
         */
        
        
        questionDicArray = [[NSMutableArray alloc] initWithArray:result[@"answer"] ];
        NSLog(@"answer-questionDicArray == %@",questionDicArray);
        
        switch (number) {
            case 0:
                self.title = @"论坛";
                titleArray = @[@"活动介绍"];
                wordArray = [[NSMutableArray alloc] initWithObjects:[wordDic objectForKey:@"info"],nil];
                NSLog(@"wordArray -- %@",wordArray);
                break;
                
            case 1:
                self.title = @"游学";
                titleArray = @[@"行程特色",@"行程安排"];//
                wordArray = [[NSMutableArray alloc] initWithObjects:[wordDic objectForKey:@"info"],[wordDic objectForKey:@"info"],nil];

                break;
                
            case 2:
                self.title = @"咨询";
                titleArray = @[@"项目介绍",@"核心优势",@"融资进度",@"目前规模",@"未来预期"];//这里分成了两个界面，一个是永道招商，一个是智放
                break;
                
            case 3:
                self.title = @"创投";
                titleArray = @[@"项目简介",@"核心优势",@"融资进度",@"目前规模",@"未来预期"];//   核心优势  融资进度  目前规模  未来预期
                wordArray = [[NSMutableArray alloc] initWithObjects:[wordDic objectForKey:@"description"],[wordDic objectForKey:@"advantage"],[wordDic objectForKey:@"financingprogress"],[wordDic objectForKey:@"scale"],[wordDic objectForKey:@"expect"],nil];//

                break;
                
            case 4:
                self.title = @"咨询";//永道招商
                titleArray = @[@"项目概况",@"品牌述求",@"策略回顾",@"效果总结"];//
                wordArray = [[NSMutableArray alloc] initWithObjects:[wordDic objectForKey:@"info"],[wordDic objectForKey:@"info"],[wordDic objectForKey:@"info"],[wordDic objectForKey:@"info"],nil];

                break;
                
            case 5:
                self.title = @"咨询";//智放
                titleArray = @[@"项目概况",@"挑战来袭",@"突围之道",@"丰硕成果"];//
                wordArray = [[NSMutableArray alloc] initWithObjects:[wordDic objectForKey:@"info"],[wordDic objectForKey:@"info"],[wordDic objectForKey:@"info"],[wordDic objectForKey:@"info"],nil];

                break;
                
            default:
                break;
        }
        
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        self.tableView.separatorStyle = NO;
        
//        theTableView.estimatedRowHeight = 44;
//        theTableView.rowHeight = UITableViewAutomaticDimension;
        
        [theTableView reloadData];
        [questionTableView reloadData];
        
        [SVProgressHUD dismiss];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
  
    [self setRightBarButton];

    self.tableView.delaysContentTouches = NO;
    
    //设置通知，显示tabbar
    [[NSNotificationCenter defaultCenter] postNotificationName:@"showBootomBar" object:self userInfo:nil ];
}

- (void)setRightBarButton
{
    UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"share01"] forState:UIControlStateNormal];
    [button setFrame:CGRectMake(0, 0, 25, 25)];
    [button addTarget:self action:@selector(rightBarButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem*rightItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    
    self.navigationItem.rightBarButtonItem= rightItem;
}

//分享按钮

- (void)rightBarButtonClicked
{
    NSString *URLString = [NSString stringWithFormat:@"%@",shareURL];
    
    BDSocialShareContent *content = [BDSocialShareContent shareContentWithDescription:@"超百万企业家都在看的商业财经类阅读客户端" url:URLString title:@"看商界"];
    //    [content addImageWithThumbImage:[UIImage imageNamed:@"icon_default_ipad"] imageUrl:self._Dict[@"thumb"]];
    UIImageView*imageview=[[UIImageView alloc]init];
    imageview.image=[UIImage imageNamed:@"icon"];
    [SVProgressHUD dismiss];
    //分享
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:nil
                                      shareText:[NSString stringWithFormat:@"%@%@",[wordDic objectForKey:@"title"],URLString]
                                     shareImage:[UIImage imageNamed:@"icon"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToQQ,UMShareToQzone,UMShareToWechatTimeline,UMShareToWechatSession,UMShareToTencent,UMShareToEmail,UMShareToSms,nil]
                                       delegate:self];
    
    [UMSocialData defaultData].extConfig.qqData.url = URLString;
    [UMSocialData defaultData].extConfig.qzoneData.url = URLString;
    [UMSocialData defaultData].extConfig.wechatTimelineData.url = URLString;
    [UMSocialData defaultData].extConfig.wechatSessionData.url = URLString;
    [UMSocialData defaultData].extConfig.sinaData.urlResource.url = URLString;
    

    [UMSocialConfig hiddenNotInstallPlatforms:@[UMShareToQQ,UMShareToQzone,UMShareToWechatSession,UMShareToWechatTimeline]];
    
 
}

-(void)didSelectSocialPlatform:(NSString *)platformName withSocialData:(UMSocialData *)socialData
{
    if (platformName == UMShareToSina) {
        socialData.shareText = [NSString stringWithFormat:@"超百万企业家都在看的商业财经类阅读客户端%@",[NSString stringWithFormat:@"%@",shareURL]];
    }
    else{
        socialData.shareText = [NSString stringWithFormat:@"超百万企业家都在看的商业财经类阅读客户端" ];
    }
}
- (void)didReceiveMemoryWarning {
    
    [SVProgressHUD dismiss];
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
 
    if ([tableView isEqual:theTableView]) {
    return 5;
    }
//    else if([tableView isEqual: questionTableView ]){
//        return 1;
//    }
    return 0;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if ([tableView isEqual:theTableView]) {
        if (section==0) {
            return 1;
        }else if (section==1){
            return wordArray.count;
        }else if (section==2){
            //        return 2;
            return 1;
        }
        else if (section==3){
        return questionDicArray.count;
        }
        else if (section==4){
            return 1;
        }
        
        else{
            return 0;
        }
    }
   
//    else if([tableView isEqual: questionTableView ]){
//        return questionDicArray.count;
//    }
//    else {
        return 0;
//    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
   
//    if ([tableView isEqual:theTableView]) {

        if (indexPath.section==0) {
            if ([self.title isEqualToString:@"游学"] || [self.title isEqualToString:@"论坛"] ) {
                return 294 ;//
                
            }
            else if([self.title isEqualToString:@"创投"]){
                return 207;
            }
            
            else {
                return 205;
            }
            
        }
    
        else if (indexPath.section==1){
            
//            UITableViewCell *higCell = [tableView dequeueReusableCellWithIdentifier:@"heightCell" forIndexPath:indexPath];
//            
//            UILabel *higLabel = (UILabel *)[higCell.contentView viewWithTag:11];
//            higLabel.text = wordArray[indexPath.row];
//            CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
//            NSLog(@"size--%f",size.height);
            
            if (cellheightArray.count >= wordArray.count) {
                NSString *heightString = cellheightArray [indexPath.row];
                return 70  + [heightString intValue];
            }
            
            return 80;
           
//            if (cellHight < 50) {
//                return cellHight + 80;
//            }
//            if ( cellHight < 100 && cellHight > 50) {
//                return cellHight + 50;
//            }
//            else {
//            return cellHight  + 30;
//            }
        }
    
        else if(indexPath.section==2){
             return 55;
        }
    
        else if(indexPath.section==3){
            return 151;
        }
        else if(indexPath.section==4){
            return 49;
        }
    
//    }
    
//    else if([tableView isEqual: questionTableView ]){
//        return 200;
//    }
    
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
//    if ([tableView isEqual:theTableView]) {
    
    for (id obj in cell.subviews)
        
    {
        
        if ([NSStringFromClass([obj class])isEqualToString:@"UITableViewCellScrollView"])
            
        {
            
            UIScrollView *scroll = (UIScrollView *) obj;
            
            scroll.delaysContentTouches =NO;
            
            break;
            
        }
        
    }
    
    if (indexPath.section==0){
        if ([self.title isEqualToString:@"游学"]) {
            
            cell = [tableView dequeueReusableCellWithIdentifier:@"studyHeadCell" forIndexPath:indexPath];
            
            if (cell==nil) {
                
                cell=[tableView dequeueReusableCellWithIdentifier:@"studyHeadCell"];
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
//            cell.userInteractionEnabled = NO;
                UILabel*label6=(UILabel*)[cell.contentView viewWithTag:102];
                label6.text = @"报名人数";
            
                if ([wordDic objectForKey:@"number"]) {
                    label6.text = [NSString stringWithFormat:@"报名人数:%@人",[wordDic objectForKey:@"number"]];
                }
            
                
                UIImageView*imageView=(UIImageView*)[cell.contentView viewWithTag:100];
                [imageView sd_setImageWithURL:[NSURL URLWithString:wordDic[@"thumb"]]];
                
                UILabel*label2=(UILabel*)[cell.contentView viewWithTag:101];
                label2.text = @"游学标题";
                label2.text = [wordDic objectForKey:@"title"];
                
                UILabel*label3=(UILabel*)[cell.contentView viewWithTag:111];
                label3.text = @"地址";
            
                if ([wordDic objectForKey:@"area"]) {
                     label3.text = [NSString stringWithFormat:@"%@%@",[wordDic objectForKey:@"area"],[wordDic objectForKey:@"address"] ];
                }
            
                
                UILabel*label4=(UILabel*)[cell.contentView viewWithTag:103];
                label4.text = @"进行中";
                NSString *timeString = [wordDic objectForKey:@"inputtime"];
                
                NSLog(@"timeString -- %@",timeString);
                //得到运动时间，需要转成年月日
                
                NSDateFormatter * formatter = [[NSDateFormatter alloc ] init];
                [formatter setDateFormat:@"YYYY-MM-dd"];
                NSString *date =  [formatter stringFromDate:[NSDate date]];
                NSString *timeLocal = [[NSString alloc] initWithFormat:@"%@", date];
                NSLog(@"timeLocal%@", timeLocal);
                
                if ([timeString integerValue] < [timeLocal integerValue]) {
                    label4.text = @"进行中";
                }
                else {
                    label4.text = @"已结束";
                    label4.backgroundColor = [UIColor blackColor];
                }
                
                UILabel*label8=(UILabel*)[cell.contentView viewWithTag:211];
                label8.text = wordDic[@"activitytime" ];
                
                
                cell.backgroundColor = UIColorFromRGB(0xf5f5f5);
                
                
                
                return cell;

            
        }
        
        
        else if ([self.title isEqualToString:@"论坛"]){
            
                cell = [tableView dequeueReusableCellWithIdentifier:@"studyHeadCell" forIndexPath:indexPath];
                if (cell==nil) {
                    cell=[tableView dequeueReusableCellWithIdentifier:@"studyHeadCell"];
                }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                UILabel*label6=(UILabel*)[cell.contentView viewWithTag:102];
                label6.text = @"参与人数";
                if ([wordDic objectForKey:@"number"]) {
                    label6.text = [NSString stringWithFormat:@"参与人数:%@人",[wordDic objectForKey:@"number"]];
                }
            
                
                UIImageView*imageView=(UIImageView*)[cell.contentView viewWithTag:100];
                [imageView sd_setImageWithURL:[NSURL URLWithString:wordDic[@"thumb"]]];
                
                UILabel*label2=(UILabel*)[cell.contentView viewWithTag:101];
                label2.text = @"论坛标题";
                label2.text = [wordDic objectForKey:@"title"];
                
                UILabel*label3=(UILabel*)[cell.contentView viewWithTag:111];
                label3.text = @"地址";
            if ([wordDic objectForKey:@"area"]) {
                label3.text = [NSString stringWithFormat:@"%@%@",[wordDic objectForKey:@"area"],[wordDic objectForKey:@"address"] ];
            }
            
                
                UILabel*label4=(UILabel*)[cell.contentView viewWithTag:103];
                label4.text = @"进行中";
                NSString *timeString = [wordDic objectForKey:@"inputtime"];
                
                NSLog(@"timeString -- %@",timeString);
                //得到运动时间，需要转成年月日
                
                NSDateFormatter * formatter = [[NSDateFormatter alloc ] init];
                [formatter setDateFormat:@"YYYY-MM-dd"];
                NSString *date =  [formatter stringFromDate:[NSDate date]];
                NSString *timeLocal = [[NSString alloc] initWithFormat:@"%@", date];
                NSLog(@"timeLocal%@", timeLocal);
                
                if ([timeString integerValue] < [timeLocal integerValue]) {
                    label4.text = @"进行中";
                }
                else {
                    label4.text = @"已结束";
                    label4.backgroundColor = [UIColor blackColor];
                }
                
                UILabel*label8=(UILabel*)[cell.contentView viewWithTag:211];
                label8.text = wordDic[@"activitytime" ];
 
                cell.backgroundColor = UIColorFromRGB(0xf5f5f5);
            
                return cell;
 
            }
            
            
            else if ([self.title isEqualToString:@"创投"]){
                
                cell = [tableView dequeueReusableCellWithIdentifier:@"chuangTouHeadCell" forIndexPath:indexPath];
                if (cell==nil) {
                    cell=[tableView dequeueReusableCellWithIdentifier:@"chuangTouHeadCell"];
                }
                
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                UIImageView*imageView=(UIImageView*)[cell.contentView viewWithTag:111];
                [imageView sd_setImageWithURL:[NSURL URLWithString:wordDic[@"thumb"]]];
                
                UILabel*label2=(UILabel*)[cell.contentView viewWithTag:211];
                label2.text = @"创投标题";
                label2.text = [wordDic objectForKey:@"title"];
                
                UILabel*label3=(UILabel*)[cell.contentView viewWithTag:311];
                label3.text = @"创始人 ";
                label3.text =  [wordDic objectForKey:@"founder"]  ;
                NSString *timeString = [wordDic objectForKey:@"inputtime"];
                
                
                cell.backgroundColor = UIColorFromRGB(0xf5f5f5);
                
                return cell;
                
            }
        
            else if ([self.title isEqualToString:@"咨询"]){
                
                cell = [tableView dequeueReusableCellWithIdentifier:@"zixunHeadViewCell" forIndexPath:indexPath];
                if (cell==nil) {
                    cell=[tableView dequeueReusableCellWithIdentifier:@"zixunHeadViewCell"];
                }
                
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                UIImageView*imageView=(UIImageView*)[cell.contentView viewWithTag:11];
                [imageView sd_setImageWithURL:[NSURL URLWithString:wordDic[@"thumb"]]];
                
                UILabel*label2=(UILabel*)[cell.contentView viewWithTag:22];
                label2.text = @"项目名称:";
                if ([wordDic objectForKey:@"title"]) {
                    label2.text = [NSString stringWithFormat:@"项目名称:%@",[wordDic objectForKey:@"title"]];
                }
                
                
                
//                cell.backgroundColor = UIColorFromRGB(0xf5f5f5);
                
                return cell;
                
            }
    }
    
    else if (indexPath.section == 1){
    
        cell = [tableView dequeueReusableCellWithIdentifier:@"wordCell" forIndexPath:indexPath];
        
        if (cell==nil) {
            
            cell=[tableView dequeueReusableCellWithIdentifier:@"wordCell"];
        }
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UILabel *title = (UILabel *)[cell.contentView viewWithTag:11];
        title.text = titleArray[indexPath.row];
        
        UILabel *wordLabel = (UILabel *)[cell.contentView viewWithTag:22];
        wordLabel.text = wordArray[indexPath.row];
        
        UIImage *lineImage = (UIImage *)[cell.contentView viewWithTag:33];
  
        [wordLabel setNumberOfLines:0];
        
 
        CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
        
        
//        [wordLabel setFrame:CGRectMake(10, 0, size.width, size.height+30)];
        
        NSLog(@"size.height == %f",size.height);
        cellHight = size.height + 60;// / 20.0f  * 16
        NSLog(@"cellHight == %d",cellHight);
       
        if (cellheightArray.count <= wordArray.count) {
            cellheightArray [indexPath.row] = [NSString stringWithFormat:@"%f", size.height ];
            
            [theTableView reloadData];
        }
        
        else {
        
            [theTableView reloadData];
        }
//        CGSize size = CGSizeMake(300, 1000);
//        CGSize labelSize = [wordLabel.text sizeWithFont:wordLabel.font constrainedToSize:size lineBreakMode:NSLineBreakByClipping];
//        wordLabel.frame = CGRectMake(wordLabel.frame.origin.x, wordLabel.frame.origin.y, labelSize.width, labelSize.height);
//        
//        cellHight = size.height + 60;

        
        
        cell.backgroundColor = UIColorFromRGB(0xf5f5f5);
        
        
        
        return cell;

    }
    
    
    else if (indexPath.section == 2){
        
        cell.userInteractionEnabled = YES;
        cell = [tableView dequeueReusableCellWithIdentifier:@"askQuestionCell" forIndexPath:indexPath];
        
        if (cell==nil) {
            
            cell=[tableView dequeueReusableCellWithIdentifier:@"askQuestionCell"];
        }
        
 
        UIButton *queButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-66, 21, 65, 26)];
        [queButton setImage:[UIImage imageNamed:@"p_btn"] forState:UIControlStateNormal];
        [queButton addTarget:self action:@selector(questionEvent) forControlEvents:UIControlEventTouchUpInside];
        [cell addSubview:queButton];
 
        
        
        tableView.delaysContentTouches = NO;
 
        cell.backgroundColor = UIColorFromRGB(0xf5f5f5);
        
        
        
        return cell;
        
    }
    
    else if (indexPath.section == 3){
        
//        cell.userInteractionEnabled = NO;
        cell = [tableView dequeueReusableCellWithIdentifier:@"questionCell" forIndexPath:indexPath];
        
        if (cell==nil) {
            
            cell=[tableView dequeueReusableCellWithIdentifier:@"questionCell"];
        }
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UIView *backView = (UIView *)[cell.contentView viewWithTag:1];
        backView.backgroundColor = [UIColor whiteColor];
        
        
        
        NSDictionary *questionDic = questionDicArray[indexPath.row];
        
        NSLog(@"questionDic -- %@",questionDic);
        UILabel*label1=(UILabel*)[cell.contentView viewWithTag:111];
        label1.text = @"188***21";
        label1.text = [questionDic objectForKey:@"name"];
        
        //           reply introduce
        UILabel*label2=(UILabel*)[cell.contentView viewWithTag:222];
        label2.text = @"问题";
        label2.text = [questionDic objectForKey:@"introduce"];
        NSLog(@"[questionDic objectForKey:@introduce]%@",[questionDic objectForKey:@"introduce"]);
        label2.numberOfLines = 0;
        [label2 sizeToFit];
        
        UIImageView *view = (UIImageView *)[cell.contentView viewWithTag:444];
        view.backgroundColor = [UIColor grayColor];
        
        NSString *replyString = [questionDic objectForKey:@"reply"];
        if (replyString.length > 0) {
            
            UILabel*label4=(UILabel*)[cell.contentView viewWithTag:555];
            label4.text = @"回答";
            label4.text = [questionDic objectForKey:@"reply"];
            label4.numberOfLines = 0;
            [label4 sizeToFit];
            NSLog(@"[questionDic objectForKey:@reply]%@",[questionDic objectForKey:@"reply"]);
            

        }
        
        UILabel*label4=(UILabel*)[cell.contentView viewWithTag:555];
        label4.text = @"回答";
        label4.text = [questionDic objectForKey:@"reply"];
        label4.numberOfLines = 0;
        [label4 sizeToFit];
        NSLog(@"[questionDic objectForKey:@reply]%@",[questionDic objectForKey:@"reply"]);
        
        UILabel*label3=(UILabel*)[cell.contentView viewWithTag:333];
        label3.text = @"2015-1-12";
        
        UILabel*label5=(UILabel*)[cell.contentView viewWithTag:666];
        label5.text = @"2015-1-12";
        
        NSString *timeString = [questionDic objectForKey:@"addtime"];
 
        NSLog(@"timeString -- %@",timeString);
        //得到运动时间，需要转成年月日
        NSString *formatString = @"YYYY-MM-dd";
        
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:formatString];
        NSDate*confromTimesp = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)[timeString intValue] - 28800];
        NSString *dateString =[NSString stringWithFormat:@"%@",[dateFormat stringFromDate:confromTimesp] ];
        NSLog(@"date: %@", dateString);
        
        label3.text = dateString;
        label5.text = dateString;

        
        
        return cell;
        
    }

    
//    }
    else if (indexPath.section == 4){
    
        cell.userInteractionEnabled = YES;
        cell = [tableView dequeueReusableCellWithIdentifier:@"baoMingCell" forIndexPath:indexPath];
        
        if (cell==nil) {
            
            cell=[tableView dequeueReusableCellWithIdentifier:@"baoMingCell"];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        UIButton *baoButton = (UIButton *)[cell.contentView viewWithTag:11011];
        [baoButton addTarget:self action:@selector(pushToBaoMin) forControlEvents:UIControlEventTouchUpInside];
        [baoButton setBackgroundColor:UIColorFromRGB(0xff8637)];
        baoButton.titleLabel.text = @"我要报名";
        
        
//        [cell.contentView addSubview:baoButton];
        
        
        switch (number) {
            case 0:
                self.title = @"论坛";
                baoButton.titleLabel.text = @"我要报名";
                break;
                
            case 1:
                self.title = @"游学";
                baoButton.titleLabel.text = @"我要报名";
                break;
                
            case 2:
                self.title = @"咨询";
                baoButton.titleLabel.text = @"我要咨询";
                break;
                
            case 3:
                self.title = @"创投";
               baoButton.titleLabel.text = @"我要投资";
                break;
                
            case 4:
                self.title = @"咨询";//永道招商
                baoButton.titleLabel.text = @"我要咨询";
                break;
                
            case 5:
                self.title = @"咨询";//智放
                baoButton.titleLabel.text = @"我要咨询";
                break;
                
            default:
                break;
        }

        return cell;
    }
    
    cell.backgroundColor = UIColorFromRGB(0xf5f5f5);
    
    
    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //    indexPath.row;
//    [tableView deselectRowAtIndexPath:indexPath animated:NO];//点击后不会有阴影
    
    if (indexPath.section == 2) {
        NSLog(@"sb");
    }
   
    
    
}

//去报名界面
- (void)pushToBaoMin{
    
    if ([self.title isEqualToString:@"论坛"] || [self.title isEqualToString:@"游学"] || [self.title isEqualToString:@"创投"]) {
        
        [self performSegueWithIdentifier:@"luntanAndTourStudyIdentifier" sender:nil];
    }

    else {
        
        [self performSegueWithIdentifier:@"PushZiXunBaoMin" sender:nil];

    }
    
}

//问题事件
- (void)questionEvent{

    
    [self performSegueWithIdentifier:@"pushAskQuestionView" sender:nil];
}

@end
